<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>个人资料</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="${ctx}/resources/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/resources/css/index.css" media="all"/>


</head>
<body class="childrenBody">


<form class="layui-form layui-row">
    <div class="layui-col-md3 layui-col-xs12 user_right">
        <div class="layui-upload-list">
            <%--<img class="layui-upload-img layui-circle userFaceBtn userAvatar" id="userFace">--%>

        </div>
        <%--<button type="button" class="layui-btn layui-btn-primary userFaceBtn"><i class="layui-icon">&#xe67c;</i> 换头像</button>--%>
        <%--<p>由于是纯静态页面，所以只能显示一张随机的图片</p>--%>
    </div>

    <div class="layui-col-md6 layui-col-xs12">
        <div class="layui-form-item">
            <label class="layui-form-label">工号</label>
            <div class="layui-input-block">
                <input type="text" value="" readonly="readonly" class="layui-input userLoginname" id="userLoginname">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">职称</label>
            <div class="layui-input-block">
                <input type="text" value="" class="layui-input userOption" Id="userPosition">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">真实姓名</label>
            <div class="layui-input-block">
                <input type="text" value="" placeholder="请输入真实姓名" lay-verify="required"
                       class="layui-input realName" id="userRealname">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">身份证号</label>
            <div class="layui-input-block">
                <input type="text" value="" lay-verify="required"
                       class="layui-input realName" id="userIdentity">
            </div>
        </div>
        <div class="layui-form-item" pane="">
            <label class="layui-form-label">性别</label>
            <div class="layui-input-block userSex" id="sex"  name="sex">
                <input type="radio" name="sexT" value="男" title="男">
                <input type="radio" name="sexT" value="女" title="女" >
            </div>

        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">手机号码</label>
            <div class="layui-input-block">
                <input type="tel" value="" placeholder="请输入手机号码" lay-verify="phone"
                       class="layui-input userPhone"
                       id="userPhone">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">所属学院</label>
            <div class="layui-input-block">
                <input type="tel" value="" lay-verify="college" class="layui-input userCollege"
                       id="userCollege">
            </div>
        </div>

        <div class="layui-form-item" id="xueyuan">
            <label class="layui-form-label">所属学院</label>
            <div class="layui-input-block">
                <select class="layui-select userCollege" id="selectCollege">
                    <option value="0"></option>
                    <option value="1">机电工程学院</option>
                    <option value="2">信息与通信学院</option>
                    <option value="3">计算机与信息安全学院</option>
                    <option value="4">艺术与设计学院</option>
                    <option value="5">商学院</option>
                    <option value="6">外国语学院</option>
                    <option value="7">数学与科学学院</option>
                    <option value="8">电子工程与自动化学院</option>
                    <option value="9">法学院</option>
                    <option value="10">材料科学与工程学院</option>
                    <option value="11">生命与环境科学学院</option>
                    <option value="12">建筑与交通工程学院</option>
                </select>
            </div>
        </div>


        <div class="layui-form-item userAddress">
            <label class="layui-form-label">家庭住址</label>
            <div class="layui-input-block">
                <input type="tel" value="" placeholder="请输入家庭住址" lay-verify="address"
                       class="layui-input userAddress"
                       id="userAddress">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">QQ</label>
            <div class="layui-input-block">
                <input type="text" value="" placeholder="请输入QQ" lay-verify="number"
                       class="layui-input userQQ"
                       id="userQQ">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">邮箱</label>
            <div class="layui-input-block">
                <input type="text" value="" placeholder="请输入邮箱" lay-verify="email"
                       class="layui-input userEmail"
                       id="userEmail">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">自我评价</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容" class="layui-textarea myself"
                          id="selfEvaluation"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn layui-btn-sm layui-btn-warm" id="doUpdate" lay-submit="doUpdate"
                        lay-filter="doUpdate" onclick="updateUserLayer()">
                    <span class="layui-icon layui-icon-edit">
                </span>立即更新
                </button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </div>
</form>


<script type="text/javascript">
    window.onload = function () {
        init();
    }

    function init() {
        var temp = document.getElementById("userLoginname");
        temp.value = "${user.loginname}"+"     (不可自由更改)";
        temp = document.getElementById("userPosition");
        temp.value = "${user.position}";
        temp = document.getElementById("userRealname");
        temp.value = "${user.realname}";
        temp = document.getElementById("userIdentity");
        temp.value = "${user.identity}";


        var wsex = "${user.sex}";
        var $ = layui.jquery;
        var layer = layui.layer;
        var form=layui.form;

        if (wsex == "1") {
            $("input[name=sexT][value=男]").prop("checked","true");
            $("input[name=sexT][value=女]").prop("checked","false");
            form.render();
        } else  {
            $("input[name=sexT][value=男]").prop("checked","false");
            $("input[name=sexT][value=女]").prop("checked","true");
            form.render();
        }

        temp = document.getElementById("userPhone");
        temp.value = "${user.phone}";

        document.getElementById("xueyuan").style.display = "none";    // 隐藏下拉框


        temp = document.getElementById("userCollege");
        temp.value = "${user.college}";

        temp = document.getElementById("userAddress");
        temp.value = "${user.address}";


        temp = document.getElementById("userQQ");
        temp.value = "${user.qq}";

        temp = document.getElementById("userEmail");
        temp.value = "${user.email}";

        temp = document.getElementById("selfEvaluation");
        temp.value = "${user.evaluation}";

    }

    function updateUserLayer() {
        var userinfo = {
            userid:${user.userid},
            identity: "",
            position: "",
            realname: "",
            loginname:${user.loginname},
            sex: "",
            phone: "",
            college: "",
            address: "",
            qq: "",
            email: "",
            evaluation: ""
        }
        userinfo.identity = document.getElementById("userIdentity").value;
        userinfo.position = document.getElementById("userPosition").value;
        userinfo.realname = document.getElementById("userRealname").value;
        var radiocheck = document.getElementsByName("sexT");
        if(radiocheck[0].checked == true){
            userinfo.sex = "1";
        }else{
            userinfo.sex = "0";
        }

        userinfo.phone = document.getElementById("userPhone").value;
        userinfo.college = document.getElementById("userCollege").value;
        userinfo.address = document.getElementById("userAddress").value;
        userinfo.qq = document.getElementById("userQQ").value;
        userinfo.email = document.getElementById("userEmail").value;
        userinfo.evaluation = document.getElementById("selfEvaluation").value;
        var url = '${ctx}/user/updateUser';
        var $ = layui.jquery;
        var layer = layui.layer;
        $.post(url, userinfo, function (res) {
            if (res.code == 200) {
            }
            layer.msg(res.msg);
        })


    }

</script>


<script type="text/javascript" src="${ctx}/resources/layui/layui.js"></script>
<script type="text/javascript" src="${ctx}/resources/page/user/userInfo.js"></script>
<script type="text/javascript" src="${ctx}/resources/js/cacheUserInfo.js"></script>
</body>
</html>